package org.dtrd.modules.evaluation.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.modules.evaluation.constant.Evaluation;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdSas;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author: QR
 * @Date: 2021/9/27-13:35
 */
@ApiModel("sas 量表信息")
@Data
public class SasInfo {

    private Integer dataId;

    private Integer patientId;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("答案列表")
    private List<Integer> answers;

    @ApiModelProperty("总分")
    private Integer scoreTotal;

    @ApiModelProperty("标准分")
    private Integer scoreStandard;

    @ApiModelProperty("严重度")
    private Float severity;

    @ApiModelProperty("输出内容")
    private String output;

    public SasInfo parseFromPo(DtrdEntEvaluationRdSas sas) {
        this.setDataId(sas.getDataId());
        this.setPatientId(sas.getPatientId());
        this.setOutput(sas.getOutput());
        this.setScoreTotal(sas.getScoreTotal());
        this.setScoreStandard(sas.getScoreStandard());
        this.setSeverity(sas.getSeverity());
        this.setCreateTime(sas.getCreateTime());
        String[] answersString = sas.getInput().split(",");
        ArrayList<Integer> answers = new ArrayList<>(Evaluation.ProblemNum.SAS.getNum());
        for (String s : answersString) {
            Integer answer = Integer.parseInt(s);
            answers.add(answer);
        }
        this.setAnswers(answers);
        return this;
    }
}
